﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WaterLocation : MonoBehaviour
{
    // Start is called before the first frame update

    Vector4[] waterPositions;
    
    // [SerializeField]
    public Material ShowPlane;
    int ChildNumber;
    
    void Start()
    {
        ChildNumber = transform.childCount;
        Shader.SetGlobalFloat("_DropCount", ChildNumber);
        waterPositions = new Vector4[ChildNumber*2];
    }

    // Update is called once per frame
    void Update()
    {
        Vector3 tmp;
        for(int i = 0; i < ChildNumber; ++i)
        {
            tmp = transform.GetChild(i).transform.position;
            waterPositions[i].x = tmp.x;
            waterPositions[i].y = tmp.y;
            waterPositions[i].z = tmp.z;
            Debug.Log(waterPositions[i]);
        }
        // waterPositions[0] = waterPositions[ChildNumber-1];
        //Shader.SetGlobalVectorArray("_DropPos", new List<Vector4>(waterPositions));
        ShowPlane.SetVectorArray("_DropPos", new List<Vector4>(waterPositions));
    }
}
